home *** CD-ROM | disk | FTP | other *** search
Text File | 1993-09-16 | 11.2 KB | 292 lines | [TEXT/CCL2] |
-
- (in-package :TRAPS)
- ;
- ; Created: Wednesday, August 14, 1991 at 12:11 PM
- ; Components.p
- ; Pascal Interface to the Macintosh Libraries
- ;
- ; Copyright Apple Computer, Inc. 1990 - 1991
- ; All rights reserved
- ;
- ;
-
- ; $IFC UNDEFINED UsingIncludes
- ; $SETC UsingIncludes := 0
- ; $ENDC
-
- ; $IFC NOT UsingIncludes
-
- ; $ENDC
-
- ; $IFC UNDEFINED UsingComponents
- ; $SETC UsingComponents := 1
-
- ; $I+
- ; $SETC ComponentsIncludes := UsingIncludes
- ; $SETC UsingIncludes := 1
- ; $IFC UNDEFINED UsingTypes
-
- (require-interface 'TYPES) ; $I $$Shell(PInterfaces)Types.p
- ; $ENDC
- ; $SETC UsingIncludes := ComponentsIncludes
-
- (defconstant $gestaltComponentMgr :|cpnt|)
-
- (defconstant $kAnyComponentType 0)
- (defconstant $kAnyComponentSubType 0)
- (defconstant $kAnyComponentManufacturer 0)
- (defconstant $kAnyComponentFlagsMask 0)
-
- (defconstant $cmpWantsRegisterMessage #X80000000)
-
- (defrecord ComponentDescription
- (componentType :OSTYPE) ; A unique 4-byte code indentifying the command set
- (componentSubType :OSTYPE) ; Particular flavor of this instance
- (componentManufacturer :OSTYPE); Vendor indentification
- (componentFlags :SIGNED-LONG); 8 each for Component,Type,SubType,Manuf/revision
- (componentFlagsMask :SIGNED-LONG); Mask for specifying which flags to consider in search, zero during registration
- )
-
- (defrecord ResourceSpec
- (resType :OSTYPE) ; 4-byte code
- (resId :SIGNED-INTEGER) ;
- )
-
- (def-mactype :COMPONENTRESOURCEPTR (find-mactype :POINTER))
- (def-mactype :COMPONENTRESOURCEHANDLE (find-mactype :HANDLE))
- (defrecord (ComponentResource :handle)
- (cd :COMPONENTDESCRIPTION) ; Registration parameters
- (component :RESOURCESPEC) ; resource where Component code is found
- (componentName :RESOURCESPEC); name string resource
- (componentInfo :RESOURCESPEC); info string resource
- (componentIcon :RESOURCESPEC); icon resource
- )
-
- ; Structure received by Component:
- (defrecord ComponentParameters
- (flags :CHARACTER) ; call modifiers: sync/async, deferred, immed, etc
- (paramSize :CHARACTER) ; size in bytes of actual parameters passed to this call
- (what :SIGNED-INTEGER) ; routine selector, negative for Component management calls
- (params (:ARRAY :SIGNED-LONG 1)); actual parameters for the indicated routine
- )
-
- (def-mactype :COMPONENT (find-mactype :POINTER))
- (defrecord ComponentRecord
- (data (:ARRAY :SIGNED-LONG 1))
- )
-
- (def-mactype :COMPONENTINSTANCE (find-mactype :POINTER))
- (defrecord ComponentInstanceRecord
- (data (:ARRAY :SIGNED-LONG 1))
- )
-
- (def-mactype :COMPONENTRESULT (find-mactype :SIGNED-LONG))
-
- (def-mactype :COMPONENTROUTINE (find-mactype :SIGNED-LONG))
-
- (def-mactype :COMPONENTFUNCTION (find-mactype :SIGNED-LONG))
-
- ; *******************************************************
- ; * *
- ; * APPLICATION LEVEL CALLS *
- ; * *
- ; *******************************************************
- ; * Component Database Add, Delete, and Query Routines
- ; *******************************************************
- ;
-
- (deftrap _REGISTERCOMPONENT ((CD :COMPONENTDESCRIPTION) (COMPONENTENTRYPOINT :SIGNED-LONG) (GLOBAL :SIGNED-INTEGER) (COMPONENTNAME :HANDLE) (COMPONENTINFO :HANDLE) (COMPONENTICON :HANDLE))
- (:STACK (:POINTER :COMPONENTRECORD))
- (:STACK-TRAP #xA82A :D0 1 CD COMPONENTENTRYPOINT GLOBAL COMPONENTNAME COMPONENTINFO COMPONENTICON))
-
- (deftrap _REGISTERCOMPONENTRESOURCE ((TR (:HANDLE :COMPONENTRESOURCE)) (GLOBAL :SIGNED-INTEGER))
- (:STACK (:POINTER :COMPONENTRECORD))
- (:STACK-TRAP #xA82A :D0 18 TR GLOBAL))
-
- (deftrap _UNREGISTERCOMPONENT ((ACOMPONENT (:POINTER :COMPONENTRECORD)))
- (:STACK :SIGNED-INTEGER)
- (:STACK-TRAP #xA82A :D0 2 ACOMPONENT))
-
-
- (deftrap _FINDNEXTCOMPONENT ((ACOMPONENT (:POINTER :COMPONENTRECORD)) (LOOKING :COMPONENTDESCRIPTION))
- (:STACK (:POINTER :COMPONENTRECORD))
- (:STACK-TRAP #xA82A :D0 4 ACOMPONENT LOOKING))
-
- (deftrap _COUNTCOMPONENTS ((LOOKING :COMPONENTDESCRIPTION))
- (:STACK :SIGNED-LONG)
- (:STACK-TRAP #xA82A :D0 3 LOOKING))
-
-
- (deftrap _GETCOMPONENTINFO ((ACOMPONENT (:POINTER :COMPONENTRECORD)) (CD :COMPONENTDESCRIPTION) (COMPONENTNAME :HANDLE) (COMPONENTINFO :HANDLE) (COMPONENTICON :HANDLE))
- (:STACK :SIGNED-INTEGER)
- (:STACK-TRAP #xA82A :D0 5 ACOMPONENT CD COMPONENTNAME COMPONENTINFO COMPONENTICON))
-
- (deftrap _GETCOMPONENTLISTMODSEED NIL
- (:STACK :SIGNED-LONG)
- (:STACK-TRAP #xA82A :D0 6))
-
- ; *******************************************************
- ; * Component Instance Allocation and dispatch routines
- ; *******************************************************
- ;
-
- (deftrap _OPENCOMPONENT ((ACOMPONENT (:POINTER :COMPONENTRECORD)))
- (:STACK (:POINTER :COMPONENTINSTANCERECORD))
- (:STACK-TRAP #xA82A :D0 7 ACOMPONENT))
-
- (deftrap _CLOSECOMPONENT ((ACOMPONENTINSTANCE (:POINTER :COMPONENTINSTANCERECORD)))
- (:STACK :SIGNED-INTEGER)
- (:STACK-TRAP #xA82A :D0 8 ACOMPONENTINSTANCE))
-
-
- (deftrap _GETCOMPONENTINSTANCEERROR ((ACOMPONENTINSTANCE (:POINTER :COMPONENTINSTANCERECORD)))
- (:STACK :SIGNED-INTEGER)
- (:STACK-TRAP #xA82A :D0 10 ACOMPONENTINSTANCE))
-
- ; direct calls to the Components
-
- (deftrap _COMPONENTFUNCTIONIMPLEMENTED ((CI (:POINTER :COMPONENTINSTANCERECORD)) (FTNNUMBER :SIGNED-INTEGER))
- (:STACK :SIGNED-LONG)
- (:STACK-TRAP #xA82A :D0 0 CI FTNNUMBER ((+ (ASH 2 16) 65533) :SIGNED-LONGINT)))
-
- (deftrap _GETCOMPONENTVERSION ((CI (:POINTER :COMPONENTINSTANCERECORD)))
- (:STACK :SIGNED-LONG)
- (:STACK-TRAP #xA82A :D0 0 CI ((+ (ASH 0 16) 65532) :SIGNED-LONGINT)))
-
- ; ****************************************************
- ; * *
- ; * CALLS MADE BY Components *
- ; * *
- ; ******************************************************
- ; ******************************************************
- ; * Required Component routines
- ; ******************************************************
-
- (defconstant $kComponentOpenSelect -1); ComponentInstance for this open
- (defconstant $kComponentCloseSelect -2); ComponentInstance for this close
- (defconstant $kComponentCanDoSelect -3); selector # being queried
- (defconstant $kComponentVersionSelect -4); no params
- (defconstant $kComponentRegisterSelect -5); no params
- (defconstant $kComponentTargetSelect -6); ComponentInstance for top of call chain
-
- ; *******************************************************
- ; * Component Management routines
- ; *******************************************************
- ;
-
- (deftrap _SETCOMPONENTINSTANCEERROR ((ACOMPONENTINSTANCE (:POINTER :COMPONENTINSTANCERECORD)) (THEERROR :SIGNED-INTEGER))
- NIL
- (:STACK-TRAP #xA82A :D0 11 ACOMPONENTINSTANCE THEERROR))
-
-
- (deftrap _GETCOMPONENTREFCON ((ACOMPONENT (:POINTER :COMPONENTRECORD)))
- (:STACK :SIGNED-LONG)
- (:STACK-TRAP #xA82A :D0 16 ACOMPONENT))
-
- (deftrap _SETCOMPONENTREFCON ((ACOMPONENT (:POINTER :COMPONENTRECORD)) (THEREFCON :SIGNED-LONG))
- NIL
- (:STACK-TRAP #xA82A :D0 17 ACOMPONENT THEREFCON))
-
-
- (deftrap _OPENCOMPONENTRESFILE ((ACOMPONENT (:POINTER :COMPONENTRECORD)))
- (:STACK :SIGNED-INTEGER)
- (:STACK-TRAP #xA82A :D0 21 ACOMPONENT))
-
- (deftrap _CLOSECOMPONENTRESFILE ((REFNUM :SIGNED-INTEGER))
- (:STACK :SIGNED-INTEGER)
- (:STACK-TRAP #xA82A :D0 24 REFNUM))
-
- ; *******************************************************
- ; * Component Instance Management routines
- ; *******************************************************
- ;
-
- (deftrap _GETCOMPONENTINSTANCESTORAGE ((ACOMPONENTINSTANCE (:POINTER :COMPONENTINSTANCERECORD)))
- (:STACK :HANDLE)
- (:STACK-TRAP #xA82A :D0 12 ACOMPONENTINSTANCE))
-
- (deftrap _SETCOMPONENTINSTANCESTORAGE ((ACOMPONENTINSTANCE (:POINTER :COMPONENTINSTANCERECORD)) (THESTORAGE :HANDLE))
- NIL
- (:STACK-TRAP #xA82A :D0 13 ACOMPONENTINSTANCE THESTORAGE))
-
-
- (deftrap _GETCOMPONENTINSTANCEA5 ((ACOMPONENTINSTANCE (:POINTER :COMPONENTINSTANCERECORD)))
- (:STACK :SIGNED-LONG)
- (:STACK-TRAP #xA82A :D0 14 ACOMPONENTINSTANCE))
-
- (deftrap _SETCOMPONENTINSTANCEA5 ((ACOMPONENTINSTANCE (:POINTER :COMPONENTINSTANCERECORD)) (THEA5 :SIGNED-LONG))
- NIL
- (:STACK-TRAP #xA82A :D0 15 ACOMPONENTINSTANCE THEA5))
-
-
- (deftrap _COUNTCOMPONENTINSTANCES ((ACOMPONENT (:POINTER :COMPONENTRECORD)))
- (:STACK :SIGNED-LONG)
- (:STACK-TRAP #xA82A :D0 19 ACOMPONENT))
-
- ; useful helper routines for convenient method dispatching
-
- (deftrap _CALLCOMPONENTFUNCTION ((PARAMS :COMPONENTPARAMETERS) (FUNC :SIGNED-LONG))
- (:STACK :SIGNED-LONG)
- (:STACK-TRAP #xA82A :D0 255 PARAMS FUNC))
-
- (deftrap _CALLCOMPONENTFUNCTIONWITHSTORAGE ((STORAGE :HANDLE) (PARAMS :COMPONENTPARAMETERS) (FUNC :SIGNED-LONG))
- (:STACK :SIGNED-LONG)
- (:STACK-TRAP #xA82A :D0 255 STORAGE PARAMS FUNC))
-
- (deftrap _DELEGATECOMPONENTCALL ((ORIGINALPARAMS :COMPONENTPARAMETERS) (CI (:POINTER :COMPONENTINSTANCERECORD)))
- (:STACK :SIGNED-LONG)
- (:STACK-TRAP #xA82A :D0 36 ORIGINALPARAMS CI))
-
- ; Set Default Component flags
- (defconstant $defaultComponentIdentical 0)
- (defconstant $defaultComponentAnyFlags 1)
- (defconstant $defaultComponentAnyManufacturer 2)
- (defconstant $defaultComponentAnySubType 4)
- (defconstant $defaultComponentAnyFlagsAnyManufacturer (+ #$DEFAULTCOMPONENTANYFLAGS #$DEFAULTCOMPONENTANYMANUFACTURER))
- (defconstant $defaultComponentAnyFlagsAnyManufacturerAnySubType (+ #$DEFAULTCOMPONENTANYFLAGS (+ #$DEFAULTCOMPONENTANYMANUFACTURER #$DEFAULTCOMPONENTANYSUBTYPE)))
-
-
- (deftrap _SETDEFAULTCOMPONENT ((ACOMPONENT (:POINTER :COMPONENTRECORD)) (FLAGS :SIGNED-INTEGER))
- (:STACK :SIGNED-INTEGER)
- (:STACK-TRAP #xA82A :D0 30 ACOMPONENT FLAGS))
-
- (deftrap _OPENDEFAULTCOMPONENT ((COMPONENTTYPE :OSTYPE) (COMPONENTSUBTYPE :OSTYPE))
- (:STACK (:POINTER :COMPONENTINSTANCERECORD))
- (:STACK-TRAP #xA82A :D0 33 COMPONENTTYPE COMPONENTSUBTYPE))
-
- (deftrap _CAPTURECOMPONENT ((CAPTUREDCOMPONENT (:POINTER :COMPONENTRECORD)) (CAPTURINGCOMPONENT (:POINTER :COMPONENTRECORD)))
- (:STACK (:POINTER :COMPONENTRECORD))
- (:STACK-TRAP #xA82A :D0 28 CAPTUREDCOMPONENT CAPTURINGCOMPONENT))
-
- (deftrap _UNCAPTURECOMPONENT ((ACOMPONENT (:POINTER :COMPONENTRECORD)))
- (:STACK :SIGNED-INTEGER)
- (:STACK-TRAP #xA82A :D0 29 ACOMPONENT))
-
- ; errors from component manager & components
- (defconstant $invalidComponentID -3000)
- (defconstant $validInstancesExist -3001)
- (defconstant $componentNotCaptured -3002)
- (defconstant $componentDontRegister -3003)
-
- (defconstant $badComponentInstance #X80008001)
- (defconstant $badComponentSelector #X80008002)
-
- ; $ENDC ; UsingComponents
-
- ; $IFC NOT UsingIncludes
-
- ; $ENDC
-
-
- (export '($BADCOMPONENTSELECTOR $BADCOMPONENTINSTANCE $COMPONENTDONTREGISTER
- $COMPONENTNOTCAPTURED $VALIDINSTANCESEXIST $INVALIDCOMPONENTID
- $DEFAULTCOMPONENTANYFLAGSANYMANUFACTURERANYSUBTYPE
- $DEFAULTCOMPONENTANYFLAGSANYMANUFACTURER $DEFAULTCOMPONENTANYSUBTYPE
- $DEFAULTCOMPONENTANYMANUFACTURER $DEFAULTCOMPONENTANYFLAGS
- $DEFAULTCOMPONENTIDENTICAL $KCOMPONENTTARGETSELECT
- $KCOMPONENTREGISTERSELECT $KCOMPONENTVERSIONSELECT
- $KCOMPONENTCANDOSELECT $KCOMPONENTCLOSESELECT $KCOMPONENTOPENSELECT
- $CMPWANTSREGISTERMESSAGE $KANYCOMPONENTFLAGSMASK
- $KANYCOMPONENTMANUFACTURER $KANYCOMPONENTSUBTYPE $KANYCOMPONENTTYPE
- $GESTALTCOMPONENTMGR))
- (provide-interface 'Components)